package cn.ewsio.dbtool.config;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
import com.jfinal.server.undertow.UndertowServer;
import com.jfinal.template.Engine;

public class DbtoolConfig extends JFinalConfig {

	public static void main(String[] args) throws Exception {
        UndertowServer.start(DbtoolConfig.class, 80, true);
    }
	
	@Override
	public void configConstant(Constants me) {
		me.setDevMode(true);
		//me.setToSlf4jLogFactory();
		
	}

	@Override
	public void configEngine(Engine arg0) {
		
	}

	@Override
	public void configHandler(Handlers arg0) {
		
	}

	@Override
	public void configInterceptor(Interceptors arg0) {
		
	}

	@Override
	public void configPlugin(Plugins plugins) {
		
		String jdbcUrl = "jdbc:mysql://10.65.255.121:3306/dev_trade?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&preferredTestQuery=select now()";
		String username = "gwbnsh_dev";
		String password = "dev_123";
		String driverClass = "com.mysql.cj.jdbc.Driver";
		
		HikariCpPlugin hikariCpPlugin = new HikariCpPlugin(jdbcUrl, username, password, driverClass);
		plugins.add(hikariCpPlugin);
		
		ActiveRecordPlugin activeRecordPlugin = new ActiveRecordPlugin(hikariCpPlugin);
		plugins.add(activeRecordPlugin);
	}

	@Override
	public void configRoute(Routes routes) {
		routes.add(new FrontRoutes());
	}

}
